
	***************
	** Create map
	***************
	
	use "$dir/data/population_projections_selectcountries.dta", clear
	
		merge 1:1 countryregion using "$dir/data/Africa_Boundaries_data.dta", gen(merge)
		gen insample=merge==3
		count if insample==1
		assert `r(N)'==8
	
		** drop islands from map
			drop if countryregion=="French Southern Territories"
		** set northern africa to missing
		** using UN statistics division definition
			replace insample=. if countryregion=="Algeria"
			replace insample=. if countryregion=="Egypt"
			replace insample=. if countryregion=="Libya"
			replace insample=. if countryregion=="Morocco"
			replace insample=. if countryregion=="Sudan"
			replace insample=. if countryregion=="Tunisia"
			replace insample=. if countryregion=="Western Sahara"
			
			egen sharessapop_total_8SSA_2020=total(sharessapop_total_2020) if insample==1
			egen sharessapop_total_8SSA_2050=total(sharessapop_total_2050) if insample==1
			egen sharessapop_60plus_8SSA_2020=total(sharessapop_60plus_2020) if insample==1
			egen sharessapop_60plus_8SSA_2050=total(sharessapop_60plus_2050) if insample==1
			
	#delimit ;
	spmap insample using "$dir/data/Africa_Boundaries_coord.dta", id(country_id)
		clmethod(unique) 
		fcolor(gs14 emidblue*0.6)
		ocolor(gray ..) osize(thin ..) 
		ndfcolor(white) ndocolor(gray)			
		legend(off)
		label(data("$dir/data/Africa_Boundaries_data_labels.dta")
		xcoord(x_cc) ycoord(y_cc) label(label) by(labtype)
		position(12 0)
		color(black black) size(vsmall vsmall))
		note("Note: Percent of total Sub-Saharan African population in 2020 in parentheses."
			"        Combined, these eight countries represent 51% of the total Sub-Saharan Africa population"
			"        and 54% of the over-60 Sub-Saharan Africa population in 2020."
			"        Population data from the UN World Population Prospects 2022.", size(vsmall));
	#delimit cr
		
	graph export "$dir/output/country_map.png", as(png) replace
		